﻿using System;
using System.ComponentModel;
using System.Diagnostics;

namespace InnovTech.Wpf.ViewModel
{
    public abstract class NotificationObject : INotifyPropertyChanged
    {


        public event PropertyChangedEventHandler PropertyChanged;
        protected void OnPropertyChanged(string propName)
        {
            VerifyPropertyName(propName);
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propName));
            }
        }

        // Force the debugger to step through this code
        [DebuggerStepThrough()]
        [Conditional("DEBUG")]
        protected void VerifyPropertyName(string name)
        {
            PropertyDescriptor prop = TypeDescriptor.GetProperties(this).Find(name, false);
            if (prop == null)
                throw new ArgumentException("Can not find a property with the given name"); 
        }

    }
}
